-
Notifications
You must be signed in to change notification settings - Fork 7
Project class interface #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2fe2045
to
9b86c19
Compare
9b86c19
to
b6ea7cc
Compare
3720002
to
b9ca4a7
Compare
ee4bf29
to
723158c
Compare
723158c
to
6f6648f
Compare
params = SimulationParams( | ||
operating_condition=AerospaceCondition(velocity_magnitude=100 * u.m / u.s), | ||
models=[ | ||
Fluid(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fluid will be added automatically, remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587
|
||
fl.Env.dev.active() | ||
|
||
SOLVER_VERSION = "workbench-24.9.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's be consistent with solver version. Let's always use release-24.11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587
project = Project.from_file( | ||
OM6wing.mesh_filename, | ||
name="wing-volume-mesh-python-upload", | ||
solver_version="workbench-24.9.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add repository-level default solver version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587, added __solver_version__
to version.py
flow360/component/project.py
Outdated
except Flow360FileError: | ||
pass | ||
raise Flow360FileError( | ||
f"{file} is not a geometry or volume mesh file required for project initialization." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in error message, list what file extension is expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587
flow360/component/project.py
Outdated
def from_file( | ||
cls, | ||
file: str = None, | ||
name: str = None, | ||
solver_version: str = None, | ||
length_unit: LengthUnitType = "m", | ||
tags: List[str] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use pydantic's "validate_call" decorator to validate inputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587, added validate_call where applicable in other user-facing methods
flow360/component/project.py
Outdated
"Project is not initialized - use Project.from_file or Project.from_cloud" | ||
) | ||
|
||
def get_simulation_json(self) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_simulation_json(self) -> dict: | |
def get_root_simulation_json(self) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587
flow360/component/project.py
Outdated
if root_type == RootType.GEOMETRY: | ||
root_api = RestApi(GeometryInterface.endpoint, id=root_id) | ||
elif root_type == RootType.VOLUME_MESH: | ||
root_api = RestApi(VolumeMeshInterfaceV2.endpoint, id=root_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do it in constructors init_webapi ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587
flow360/component/project.py
Outdated
root_api = RestApi(VolumeMeshInterfaceV2.endpoint, id=root_id) | ||
resp = root_api.get(method="simulation/file", params={"type": "simulation"}) | ||
if not isinstance(resp, dict) or "simulationJson" not in resp: | ||
raise Flow360WebError("Root item type or ID is missing from project metadata") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the message seems be incorrect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587
flow360/component/project.py
Outdated
for _, old_entity in enumerate(old_draft_entities): | ||
try: | ||
registry.find_by_naming_pattern(old_entity.name) | ||
except ValueError: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand intention of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pasted over from the previous cloud class but you're right - this looks like it has no effect. I'll double-check with Ben.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587, but might need another small change, see DM on Slack
flow360/component/project.py
Outdated
RestApi(ProjectInterface.endpoint, id=self.metadata.id).patch( | ||
json={ | ||
"lastOpenItemId": destination_id, | ||
"lastOpenItemType": target.__name__, | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialise this in constructor and run:
RestApi(ProjectInterface.endpoint, id=self.metadata.id).patch( | |
json={ | |
"lastOpenItemId": destination_id, | |
"lastOpenItemType": target.__name__, | |
} | |
) | |
self.webapi.patch( | |
json={ | |
"lastOpenItemId": destination_id, | |
"lastOpenItemType": target.__name__, | |
} | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ba5587
flow360/component/project.py
Outdated
Whether to fork the case (default is True). | ||
""" | ||
self._check_initialized() | ||
self._case = self._run( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if a user runs a batch of cases by tweaking parameter? Then _case will get overwritten every time a new case is submitted? Can we instead create a draft_name (which IIRC is the case/VM/SM name) to asset(or just asset ID) map instead? @maciej-flexcompute what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I was initially under the impression that these properties will hold the most recently opened assets (geometry, surface mesh, volume mesh, case) but in case of batch runs we should probably keep some history of all loaded asset objects... Maybe we could have a history
interface of sorts where the user can see previous assets?
Something like
for i in range(0, 50):
project.run_case(...)
# Show most recent one
case = project.case
# Show history of all project runs
for id in project.case_history():
# Load the project with a specified ID
case = project.case(id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. We need to fix this though since I expect the major use for python client is batch submission.
Another simple way is to just return the Case
obj and ask user to manage their cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this interface in 3b7aa70, check project_from_file_geometry_multiple_runs.py
for reference.
076877a
to
c90e70f
Compare
71a5c39
to
2939dfa
Compare
2939dfa
to
3b7aa70
Compare
8b2c75c
to
99f2143
Compare
* Added initial version of the Project class interface * Added examples, remove usages of cloud static functions * Entity info injection during _run() * Style fixes * Fix webapi test * Fix examples, fix from_cloud * Add case fork option * Switched docstrings to numpy style * Fix PR feedback * Fix PR feedback #2 * Fix PR feedback #3 * Fix PR feedback #4 --------- Co-authored-by: Ben <106089368+benflexcompute@users.noreply.github.com>
* Added initial version of the Project class interface * Added examples, remove usages of cloud static functions * Entity info injection during _run() * Style fixes * Fix webapi test * Fix examples, fix from_cloud * Add case fork option * Switched docstrings to numpy style * Fix PR feedback * Fix PR feedback #2 * Fix PR feedback #3 * Fix PR feedback #4 --------- Co-authored-by: andrzej-krupka <156919532+andrzej-krupka@users.noreply.github.com>
No description provided.